package hu;

import java.util.*;

public class hu55 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            if(i % 7 == 0){
                sum++;
                continue;
            }
            int p = i;
            while(p / 10 > 0){
                if(p / 10 == 7 || p % 10 == 7){
                    sum++;
                    break;
                }
                p = p / 10;
            }

        }
        System.out.println(sum);
    }
}
